﻿using System;
using System.Collections.Generic;
using System.Data;

using MyLibrary.ThreeLayer.DataAccess.MetaData;
using MyLibrary.ThreeLayer.DataAccess.QueryLanguage;

namespace MyLibrary.ThreeLayer.DataAccess.Interface
{
    public interface ISQLCommandBuilder<T> where T : class, new()
    {
        //删除语句需要实现的接口
        IDbCommand BuildDeleteCommand(IDbProvider provider, MappingCollection collection);
        IDbCommand BuildDeleteCommand(IDbProvider provider, MappingCollection collection, ConditionExpression expression);
        IDbCommand BuildDeleteCommand(IDbProvider provider, MappingCollection collection, T entity);
        IDbCommand BuildDeleteCommand(IDbProvider provider, MappingCollection collection, MappingField key, object keyValue);
        IDbCommand BuildDeleteCommand(IDbProvider provider, object entity1, object entity2);
        IDbCommand BuildDeleteCommand(IDbProvider provider, MappingCollection collection, object keyValue);
        //插入语句需要实现的接口
        IDbCommand BuildInsertCommand(IDbProvider provider, MappingCollection collection, T entity);
        IDbCommand BuildInsertCommand(IDbProvider provider, object entity1, object entity2);
        //查询语句需要实现的接口
        IDbCommand BuildJoinQueryCommand(IDbProvider provider, MappingCollection collection, ConditionExpression expression);
        IDbCommand BuildQueryCommand(IDbProvider provider, MappingCollection collection, ConditionExpression expression);
        IDbCommand BuildQueryCommand(IDbProvider provider, MappingCollection collection);
        IDbCommand BuildQueryCommand(IDbProvider provider, MappingCollection collection, MappingField selectKey, object keyValue);
        IDbCommand BuildQueryCommand(IDbProvider provider, MappingCollection collection, IList<MappingField> keys, T entity);
        IDbCommand BuildQueryCommand(IDbProvider provider, MappingCollection collection, T entity);
        IDbCommand BuildQueryCommand(IDbProvider provider, QueryExpression expression);
        //更新语句需要实现的接口
        IDbCommand BuildUpdateCommand(IDbProvider provider, MappingCollection collection, T entity);
        IDbCommand BuildUpdateCommand(IDbProvider provider, MappingCollection collection, T entity, ConditionExpression expression);
        IDbCommand BuildUpdateCommand(IDbProvider provider, MappingCollection collection, T entity, ConditionExpression expression, IQueryField[] fields);
        IDbCommand BuildUpdateCommand(IDbProvider provider, MappingCollection collection, T entity, ConditionExpression expression, string updateFields);
    }
}
